﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DotNet.Random
{
    /// <summary>
    /// int string 构建类
    /// </summary>
    public class BuildRandService
    {
        /// <summary>
        /// Rands the specified serial.
        /// string随机方法，
        /// </summary>
        /// <param name="serial">The serial.随机序列</param>
        /// <param name="length">The length.生成长度</param>
        /// <returns>指定长度string集合</returns>
        public IList<string> Rand(IList<string> serial, int length)
        {
            var res = new List<string>();
            int randValue = -1;
            System.Random rand = new System.Random(unchecked((int)System.DateTime.Now.Ticks));
            for (int i = 0; i < length; i++)
            {
                randValue = rand.Next(0, serial.Count - 1);
                res.Add(serial[randValue]);
            }
            return res;
        }

        /// <summary>
        /// Rands the specified serial.
        /// int 随机方法
        /// </summary>
        /// <param name="serial">The serial.随机序列</param>
        /// <param name="length">The length.生成长度</param>
        /// <returns>指定长度int集合</returns>
        public IList<int> Rand(IList<int> serial, int length)
        {
            var res = new List<int>();
            int randValue = -1;
            System.Random rand = new System.Random(unchecked((int)System.DateTime.Now.Ticks));
            for (int i = 0; i < length; i++)
            {
                randValue = rand.Next(0, serial.Count - 1);
                res.Add(serial[randValue]);
            }
            return res;
        }
    }
}
